package com.atmilan.quartz.provider;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.atmilan.quartz.model.dto.buyer.BuyerBrandResult;
import com.atmilan.quartz.model.dto.buyer.BuyerCateResult;
import com.atmilan.quartz.model.dto.buyer.BuyerProductResDTO;


/**
 * @author hupeng
 */
@FeignClient(name = "buyer-client", url = "${buyer.url}", configuration = BuyerFeignConfiguration.class, fallback = IBuyerProvider.BuyerFallback.class)
public interface IBuyerProvider {
    @GetMapping
    @ResponseBody
    BuyerProductResDTO getProduct(@RequestParam("op") String op,
                                  @RequestParam("action") String action,
                                  @RequestParam("r") String random,
                                  @RequestParam("t") String timestamp,
                                  @RequestParam("appkey") String appKey,
                                  @RequestParam("appsecret") String appSecret,
                                  @RequestParam("s") String signature,
                                  @RequestParam("p") Integer page,
                                  @RequestParam("n") Integer size,
                                  @RequestParam("stock") Integer stock);

    @GetMapping
    @ResponseBody
    String getProductStr(@RequestParam("op") String op,
                                  @RequestParam("action") String action,
                                  @RequestParam("r") String random,
                                  @RequestParam("t") String timestamp,
                                  @RequestParam("appkey") String appKey,
                                  @RequestParam("appsecret") String appSecret,
                                  @RequestParam("s") String signature,
                                  @RequestParam("p") Integer page,
                                  @RequestParam("n") Integer size);
    @GetMapping
    @ResponseBody
    BuyerCateResult getCate(@RequestParam("op") String op,
                            @RequestParam("action") String action,
                            @RequestParam("r") String random,
                            @RequestParam("t") String timestamp,
                            @RequestParam("appkey") String appKey,
                            @RequestParam("appsecret") String appSecret,
                            @RequestParam("s") String signature);

    @GetMapping
    @ResponseBody
    BuyerBrandResult getBrand(@RequestParam("op") String op,
                              @RequestParam("action") String action,
                              @RequestParam("r") String random,
                              @RequestParam("t") String timestamp,
                              @RequestParam("appkey") String appKey,
                              @RequestParam("appsecret") String appSecret,
                              @RequestParam("s") String signature);

    @GetMapping
    @ResponseBody
    String getBrandString(@RequestParam("op") String op,
                              @RequestParam("action") String action,
                              @RequestParam("r") String random,
                              @RequestParam("t") String timestamp,
                              @RequestParam("appkey") String appKey,
                              @RequestParam("appsecret") String appSecret,
                              @RequestParam("s") String signature);
    @PostMapping
    @ResponseBody
    String pushOrder(@RequestParam("op") String op,
                     @RequestParam("action") String action,
                     @RequestParam("r") String random,
                     @RequestParam("t") String timestamp,
                     @RequestParam("appkey") String appKey,
                     @RequestParam("appsecret") String appSecret,
                     @RequestParam("s") String signature,
                     @RequestBody String orderInfo
                    );

    @Component
    class BuyerFallback implements IBuyerProvider {

        @Override
        public BuyerProductResDTO getProduct(String op, String action, String random, String timestamp, String appKey, String appSecret, String signature, Integer page, Integer size, Integer stock) {
            return null;
        }

        @Override
        public BuyerCateResult getCate(String op, String action, String random, String timestamp, String appKey, String appSecret, String signature) {
            return null;
        }

        @Override
        public BuyerBrandResult getBrand(String op, String action, String random, String timestamp, String appKey, String appSecret, String signature) {
            return null;
        }

        @Override
        public String getProductStr(String op, String action, String random, String timestamp, String appKey, String appSecret, String signature, Integer page, Integer size) {
            return null;
        }

        @Override
        public String getBrandString(String op, String action, String random, String timestamp, String appKey, String appSecret, String signature) {
            return null;
        }

        @Override
        public String pushOrder(String op, String action, String random, String timestamp, String appKey, String appSecret, String signature,String orderInfo) {
            return null;
        }
    }


}
